package com.jiyinit.web.core.activiti.service;

import com.jiyinit.web.core.activiti.dao.MobileDataStatisticsDao;
import com.jiyinit.web.core.activiti.dto.AttendanceRequest;
import com.jiyinit.web.core.activiti.vo.AttendanceEntity;
import com.jiyinit.web.core.business.entity.TabCoreOrgEntity;
import com.jiyinit.web.core.business.service.OrgServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author liuzongguang
 * @date 2018/7/20.
 */
@Service("mobileDataStatisticsServiceImpl")
public class MobileDataStatisticsServiceImpl {
    /**
     * 日志对象
     */
    private static Logger logger = LoggerFactory.getLogger(MobileDataStatisticsServiceImpl.class);

    @Resource(name = "core.mobileDataStatisticsDao")
    private MobileDataStatisticsDao mobileDataStatisticsDao;

    @Resource(name = "core.orgServiceImpl")
    private OrgServiceImpl orgService;

    public List<AttendanceEntity> getAttendanceInfo(AttendanceRequest request)
    {
        //根据当前登录者的orgId，获取顶级机构id
        Integer parentId = orgService.getTopParentOrgId(Integer.parseInt(request.getOrgId()));
        //查询出顶级机构下属所有子机构
        List<TabCoreOrgEntity> orgList = orgService.getChildOrgById(parentId);
        //查询出所有子机构下的所有用户考勤情况
        List<AttendanceEntity> result =  mobileDataStatisticsDao.getAttendanceInfo(request,orgList);
        return result;
    }
}
